package xyz.app.dependencies;

import lombok.NonNull;
import xyz.app.accessors.DbAccessor;
import xyz.app.AbstractDomain;

import java.util.Collection;
import java.util.stream.Collectors;

public interface HasDomainMembers<T extends AbstractDomain> extends DbAccessor<T> {

    default void configureGraph(@NonNull Object rawGraph) {
        var graphNodes = graphNodes();
        daoRegistry().configureGraph(graphNodes, rawGraph);
    }

    Collection<MemberAccessor> memberAccessors();

    private Collection<String> graphNodes() {
        return memberAccessors().stream()
                .map(MemberAccessor::getName)
                .collect(Collectors.toSet());
    }
}